home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
1Shareware Extravaganza - Disc 2
/
Shareware Extravaganza - Over 25,000 Programs (The Ultimate Shareware Company)(Disc 2 of 4)(1993).iso
/
comms
/
bix.slt
< prev
next >
Wrap
Text File
|
1991-08-04
|
4KB
|
212 lines
//
// bix.slt
//
// A Telix SALT script for logging onto BIX through Tymnet.
//
// D. H. Rifkind 1 Dec 89
//
// This was originally part of a much longer "blink" script
// that logged on, captured all new messages and mail, and
// logged off again...in case you're wondering about the
// unnecessary complexity of things like errmsg() and
// conn_wait().
//
// Configuration parameters
str dialing_entry[] = "1"; // Dialing directory entry for BIX
str user_name[] = "your_name"; // Your BIX user name
int max_dial_retries = 5; // Maximum times to redial (will hang
// up and try again on excessive line
// noise)
int max_connect_retries = 25; // Maximum times to retry connecting to
// BIX (if host busy)
//
// main
//
main()
{
int status;
int logged_on = 0;
status = log_on();
return status;
}
//
// log_on
//
// Dials Tymnet, negotiates through and logs on to BIX.
// Returns 1 on failure, 0 on success.
//
log_on()
{
int dial_retry, connect_retry;
int log_in_1, log_in_2, enter_name;
int line_noise_1, line_noise_2;
int bad_news;
int connect_wait, retry_pause;
int got_log_in;
for (dial_retry = 0; dial_retry < max_dial_retries; ++dial_retry) {
if (!carrier()) {
if (!dial(dialing_entry, 10, 1))
goto HANGUP_AND_RETRY;
delay_scr(5);
if (!carrier())
goto HANGUP_AND_RETRY;
}
_local_echo = 1; // Possibly got reset from directory
track_free(0);
log_in_1 = track("log in: ", 0);
log_in_2 = track("user name: ", 0);
bad_news = track("system maintenance", 0);
enter_name = track("Name? ", 0);
delay_scr(50); // Wait out Tymnet garbage
cputc('a'); // Terminal identifier
line_noise_1 = track("{", 0); // Or enter your favorite line noise
line_noise_2 = track("~", 0); // characters here
for (connect_retry = -1; connect_retry < max_connect_retries; ++connect_retry) {
timer_free(0);
connect_wait = timer_start(300);
retry_pause = timer_start(50);
for (got_log_in = 0;;) {
terminal();
if (time_up(connect_wait) || !carrier())
goto HANGUP_AND_RETRY;
if (track_hit(line_noise_1) || track_hit(line_noise_2))
goto HANGUP_AND_RETRY;
if (track_hit(bad_news)) {
waitfor("log in:", 30);
return errmsg("BIX is closed");
}
if (track_hit(log_in_1) || track_hit(log_in_2)) {
got_log_in = 1;
timer_restart(retry_pause, 50);
}
if (got_log_in) {
if (connect_retry < 0 || time_up(retry_pause))
break;
}
if (track_hit(enter_name))
goto ENTER_USER_NAME;
}
cputc('^H'); // Turn off Tymnet echo
xputs("bix^M");
}
return errmsg("Can't get through to BIX");
ENTER_USER_NAME:
xputs(user_name); xputc('^M');
if (!conn_wait("Password: ", 30))
goto HANGUP_AND_RETRY;
if (strlen(_entry_pass) != 0) {
printc('^M');
cputs(_entry_pass); cputc('^M');
}
track_free(0); // No sense tracking that stuff now
return 0;
HANGUP_AND_RETRY:
if (carrier()) {
if (!hangup())
return 1;
}
}
return errmsg("No response from Tymnet");
}
//
// errmsg
//
// Displays an error message on the screen. Returns 1
// so that it can be used like:
//
// return errmsg("Modem caught fire");
//
errmsg(str msg)
{
printsc("^M^J*** ");
prints(msg);
return 1;
}
//
// xputs
//
// Writes a string both to the screen and the serial port.
//
xputs(str s)
{
printsc(s);
cputs(s);
}
//
// xputc
//
// Writes a single character to the screen and serial port.
//
xputc(int c)
{
printc(c);
cputc(c);
}
//
// conn_wait
//
// Like waitfor(), but fails if the connection is lost.
//
conn_wait(str s, int t)
{
int track_s;
int timer_t;
int success = 0;
// Cautious use of timer and track handles.
track_s = track(s, 0);
timer_t = timer_start(t * 10);
do {
terminal();
if (!carrier() || time_up(timer_t))
break;
} while ((success = track_hit(track_s)) == 0);
track_free(track_s);
timer_free(timer_t);
return success;
}
// End of bix.slt